# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
#
# This PKGBUILD was extracted from Manjaro Linux and adapted to our style
# and later reworked to match https://github.com/arch-linux-calamares-installer/alci-pkgbuild/blob/master/calamares/alci-calamares/calamares-3.3.0.230321-04/PKGBUILD
#
# Old Maintainer: Philip Müller <philm[at]manjaro[dot]org>

pkgname=calamares
pkgver=3.3.0.23.0321
pkgrel=1
epoch=3
pkgdesc='Distribution-independent installer framework.'
url='https://github.com/calamares/calamares'
arch=('x86_64' 'aarch64')
license=('LGPL')
depends=('kconfig' 'kcoreaddons' 'kiconthemes' 'ki18n' 'kio' 'solid' 'yaml-cpp'
         'kpmcore' 'mkinitcpio-openswap' 'boost-libs' 'ckbcomp' 'hwinfo'
         'qt5-svg' 'polkit-qt5' 'gtk-update-icon-cache' 'plasma-framework'
         'qt5-xmlpatterns' 'squashfs-tools' 'libpwquality' 'appstream-qt' 'icu'
         'efibootmgr' 'kdbusaddons' 'python')
makedepends=('extra-cmake-modules' 'qt5-tools' 'qt5-translations' 'git' 'boost'
             'kparts' 'kdbusaddons' 'python')
backup=('usr/share/calamares/modules/bootloader.conf'
        'usr/share/calamares/modules/displaymanager.conf'
        'usr/share/calamares/modules/initcpio.conf'
        'usr/share/calamares/modules/unpackfs.conf')
source=($pkgname::git+https://github.com/calamares/calamares#commit=4f2ab85)
sha512sums=('SKIP')

prepare() {
  cd "$pkgname"

  _ver="$(cat CMakeLists.txt | grep -m3 -e "  VERSION" | grep -o "[[:digit:]]*" | xargs | sed s'/ /./g')"
  sed -i -e \
    "s|\${CALAMARES_VERSION_MAJOR}.\${CALAMARES_VERSION_MINOR}.\${CALAMARES_VERSION_PATCH}|${_ver}-${pkgrel}|g" \
    CMakeLists.txt
  sed -i -e "s|CALAMARES_VERSION_RC 1|CALAMARES_VERSION_RC 0|g" CMakeLists.txt
}

build() {
  cd "$pkgname"

  mkdir -p build && cd build

  cmake .. \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/usr \
  -DCMAKE_INSTALL_LIBDIR=lib \
  -DWITH_PYTHONQT=OFF \
  -DWITH_KF5DBus=OFF \
  -DBoost_NO_BOOST_CMAKE=ON \
  -DWEBVIEW_FORCE_WEBKIT=OFF \
  -DSKIP_MODULES="webview tracking interactiveterminal initramfs \
  initramfscfg dracut dracutlukscfg \
  dummyprocess dummypython dummycpp \
  dummypythonqt services-openrc \
  keyboardq localeq welcomeq"

  make
}

package() {
  cd "$pkgname/build"

  make DESTDIR="$pkgdir" install
}

